package com.thinkfit.jy.presenter;

import com.common.lib.bean.VideoBean;
import com.common.lib.mvp.BasePresenter;
import com.common.lib.network.HttpListener;
import com.common.lib.network.HttpMethods;
import com.common.lib.network.HttpObserver;
import com.thinkfit.jy.contract.TVContract;

import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.util.ArrayList;

public class TVPresenter extends BasePresenter<TVContract.View> implements TVContract.Presenter {

    public TVPresenter(@NotNull TVContract.View rootView) {
        super(rootView);
    }


    @Override
    public void getTVData() {
        HttpMethods.Companion.getInstance().getTVData(
                new HttpObserver(false, getRootView(), new HttpListener<ArrayList<VideoBean>>() {
                    @Override
                    public void onSuccess(@Nullable ArrayList<VideoBean> list) {
                        if (getRootView() == null) {
                            return;
                        }
                        getRootView().getTVDataSuccess(list);
                    }

                    @Override
                    public void dataError(@Nullable int code, @Nullable String msg) {
                    }

                    @Override
                    public void connectError(@Nullable Throwable e) {
                    }
                }, getCompositeDisposable()));
    }
}
